$(function() {

alert('bug');

function loadTours(){

//alert('start');
var FEED_URL = "http://hot-spot.rs/en/tours/rss.html";


	
	var xhr = new XMLHttpRequest({
    mozSystem: true
   });
   xhr.open('GET', FEED_URL, true);
   xhr.responseType = 'xml';

  //xhr.timeout = fb.operationsTimeout || fb.DEFAULT_TIMEOUT;

  xhr.onload = function(e) {
    if (xhr.status === 200 || xhr.status === 0) {
		//alert('ok');
		$(e.target.response).find('item').each(function(){
						
						var title = $(this).find("title").text();
						var link = $(this).find("link").text();
						var description = $(this).find("description").text();
						var sItem = '<div data-role="collapsible"  data-collapsed="true"><h2>' + title + '</h2><p>'
							+ description.replace("<p>","<span>").replace("</p>","</span>").replace("<![CDATA[","").replace("]]>","");  
							+ '<a href="' + link + '">More...</a>'
							+ '</p></div>'
						$("#lstTours").append( sItem );
					});	
		$("#lstTours").collapsibleset( "refresh" );
		$("#info").text("Done!");
		$("#loadFeed").hide();
		
		/*
      var mblob = e.target.response;
      if (typeof callback === 'function')
        self.setTimeout(function() {
          callback(mblob);
        },0);
	*/	
    }
    else {
		alert("error: " + xhr.status + " " + xhr.statusText);

    }
  }; // onload
	$("#info").text("Starting...");
	xhr.send();
	$("#info").text("Retrieving...");
}

$("#loadFeed").click( function(){ alert('load');  } );

self.setTimeout(loadTours, 1000);

});

